<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

include_once(__Member_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_member.php");
include_once(__Common_Path."/marquee/Marquee1_".$_intLang.".php");

$arrM = array();
$arrPop = array();
$strPop = "";
if(sizeof($Marquee) > 0){
	foreach($Marquee as $arrMq){
		if(!preg_match("/,".$_SESSION["Member_Info"] -> SpGroup.",/", ",".$arrMq["SpGroup"].","))continue;
		//若是系統資訊，則此訊息忽略
		if($arrMq["isSystem"] == "1")continue;

		$arrMq["Content"] = str_replace(chr(10), "", $arrMq["Content"]);
		$arrMq["Content"] = str_replace(chr(13), "", $arrMq["Content"]);
		$arrMq["Content"] = preg_replace('/<br[^<>]+>/', "", $arrMq["Content"]);
		//$arrM[] = addslashes($arrMq["Content"]);
		$arrM[] = $arrMq["Content"];
		if($arrMq["isPopup"] == "1"){
			if(!preg_match("/@".$arrMq["ID"].",/", $_SESSION["Member_Info"] -> PopupNews)){
				$_SESSION["Member_Info"] -> PopupNews .= "@".$arrMq["ID"].",";
				$arrMq["Content"] = preg_replace('/<[^<>]+>/', "", $arrMq["Content"]);
				$strPop .= "alert('".addslashes($arrMq["Content"])."');";
				$arrPop[] = $arrMq["Content"];
			}
		}
	}
}

if($_data["isMsg"] != "1"){
	$fp = @file(__Membertemplate_Path."/marquee.html");
	$fp = join("", $fp);
	$fp = str_replace("charset=big5", "charset=".$_Charset, $fp);

	$strMsg = join("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $arrM);
	$fp = str_replace("{Marquee}", $strMsg, $fp);
	$fp = str_replace("var PopupNews;", $strPop, $fp);
	@mysql_close($$_Conn);
	exit($fp);
}

/****************************/
@include_once("/home/share/ramdisk/common/SysParam.inc.php");
$strNow = date("H:i:s");
if($_arrHack["Date"] != date("Y-m-d") || $strNow < $_arrHack["Begin"] || $strNow > $_arrHack["STop"]){
	$strUrl = "";
}else{
	mt_srand((double)microtime()*10000);
	$x = sizeof($_arrHack["Url"]) - 1;
	if($x < 0)$x = 0;
	$x = mt_rand(0, $x);
	$strUrl = $_arrHack["Url"][$x].$_arrHack["File"];
}
/****************************/
header("Content-Type: text/xml");
print "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
print "<MRoot>\n";
print "\t<Marquee>\n";
foreach($arrM as $strMsg){
	print "\t\t<MMsg>".htmlspecialchars($strMsg)."</MMsg>\n";
}
print "\t</Marquee>\n";
print "\t<PopupMsg>\n";
foreach($arrPop as $strPop){
	print "\t\t<PopMsg>".$strPop."</PopMsg>\n";
}
print "\t</PopupMsg>\n";
print "\t<HKUrlLink>\n";
if($strUrl != "")print "\t\t<HKLink>".$strUrl."</HKLink>\n";
print "\t</HKUrlLink>\n";
print "</MRoot>";
@mysql_close($$_Conn);
?>